package com.ywdnf.javaruntimecompile.fileobject;

import java.net.URI;
import javax.tools.SimpleJavaFileObject;

/**
 * TODO
 *
 * @author lss
 * @date 2019-05-09, Thu
 */
public class JavaSourceFromString extends SimpleJavaFileObject {


  private final String code;
  private final String name;


  public JavaSourceFromString(String name, String code) {
    super(URI.create("string:///" + name.replace('.', '/') + Kind.SOURCE.extension),
        Kind.SOURCE);
    this.code = code;
    this.name = name;
  }

  @Override
  public CharSequence getCharContent(boolean ignoreEncodingErrors) {
    return code;
  }
}
